
<?php include './application/views/top.php'; ?>
<script src="/static/js/gsdai.js"></script>
<script src="/static/js/ajaxfileupload.js"></script>
<script src="/static/js/My97DatePicker/WdatePicker.js"></script>
<script src="/static/js/formCheck.js"></script>

<div class="clear"></div>
<div class="user_bottom all"></div>
<div class="clear h50"></div>
<div class="layout uc">
	<?php include './application/views/user/left.php'; ?>
	<div class="right">
		<div class="menu_list"><?php include './application/views/user/menu.php'; ?></div>
        <div class="cont">
        	<ul class="tbt">
            	<li class="w218">借款标题</li>
                <li class="w200">投资金额</li>
                <li class="w200">待收金额</li>
                <li class="w150">最后还款时间</li>
                <li class="w150 npr">操作</li>
			</ul>
            <?php foreach ($list as $val){?>
        	<ul class="tbc">
            	<li class="w218"><?php echo $val['title'];?></li>
            	<li class="w200"><?php echo $val['account'];?></li>
                <li class="w200"><?php echo $val['t_repay_account'];?></li>
                <li class="w150"><?php echo date('Y-m-d',$val['last_repay_time']);?></li>
            	<li class="w150 npr"><a href="javascript:void(0);" class="zrbutton" onclick="show_post_div(<?php echo $val['tender_id'];?>,<?php echo $val['account'];?>);">转让</a></li>
			</ul>
        	<?php }?>
<script type="text/javascript">
function show_post_div(tender_id,account){
	document.getElementById('post_div').style.display='';
	document.getElementById('tender_id').value=tender_id;
	document.getElementById('zhje').innerHTML=account;
	document.getElementById('o_account').value=account;
}
function checkApr(){
	var val = document.getElementById('apr').value;
	val = parseFloat(val);
	account = document.getElementById('o_account').value;
	if(!val){
		//alert('请填写有效的折让率');
		document.getElementById('apr').value="";
		document.getElementById('zhje').innerHTML=account;
		document.getElementById("discount_account").value = account;
		$('#dialog').dialog({
			modal:true,
			title:'系统提示',
			buttons:{"确定":function(){$(this).dialog("close");}},
		});
		$("#msg").html('请填写有效的折让率');
		return;
	}
	if(val<0.5 || val>11.5){
		//alert('折让率必须为0.5%-11.5%之间');
		document.getElementById('apr').value="";
		document.getElementById('zhje').innerHTML=account;
		document.getElementById("discount_account").value = account;
		$('#dialog').dialog({
			modal:true,
			title:'系统提示',
			buttons:{"确定":function(){$(this).dialog("close");}},
		});
		$("#msg").html('折让率必须为0.5%-11.5%之间');
		return;
	}
	val = val.toFixed(2);
	document.getElementById('apr').value=val;
	var new_acc = 0;
	var acc = document.getElementById('o_account').value;
	new_acc = acc*(100-val)/100;
	document.getElementById("zhje").innerHTML = new_acc;
	document.getElementById("discount_account").value = new_acc;

}

function checksub(){
	if(document.getElementById('title').value==''){
		//alert('标题不能为空');
		$('#dialog').dialog({
			modal:true,
			title:'系统提示',
			buttons:{"确定":function(){$(this).dialog("close");}},
		});
		$("#msg").html('请选择标题');
		return false;
	}
	var val = document.getElementById('apr').value;
	val = parseFloat(val);
	account = document.getElementById('o_account').value;
	if(!val){
		//alert('请填写有效的折让率');
		document.getElementById('apr').value="";
		document.getElementById('zhje').innerHTML=account;
		document.getElementById("discount_account").value = account;
		$('#dialog').dialog({
			modal:true,
			title:'系统提示',
			buttons:{"确定":function(){$(this).dialog("close");}},
		});
		$("#msg").html('请填写有效的折让率');
		return false;
		return false;
	}
	if(val<0.5 || val>11.5){
		//alert('折让率必须为0.5%-11.5%之间');
		document.getElementById('apr').value="";
		document.getElementById('zhje').innerHTML=account;
		document.getElementById("discount_account").value = account;
		$('#dialog').dialog({
			modal:true,
			title:'系统提示',
			buttons:{"确定":function(){$(this).dialog("close");}},
		});
		$("#msg").html('折让率必须为0.5%-11.5%之间');
		return false;
	}

	return true;
}

function tosub(){
	var options = {
		url : '/userborrow/dotransfer',
		beforeSubmit:  checksub,
		dataType: "text",
		type:"post",
		success : function(ret) {
			$('#dialog').dialog({
				modal:true,
				title:'系统提示',
				buttons:{"确定":function(){$(this).dialog("close");}},
				close: function() {
					location="/userborrow/transfer.html";
				}
			});
			$("#msg").html(ret);
		}
	};
	$("#form").ajaxSubmit(options);
	return false;
}
function closediv(){
	document.getElementById('post_div').style.display='none';
}
</script>
			<div id="post_div" class="trwindows" style="position: absolute;margin-left: auto;margin-right: auto; top:0px;background-color:#fff;width:600px;border:8px solid #666666;display:none;">
				<div style="margin:0 auto;float:right;"><img src="/static/images/close.png" width="30" onclick="closediv();" style="cursor:pointer;"></div>
				<form id="form" action="/userborrow/dotransfer" method="post">
				<input type="hidden" name="tender_id" id="tender_id" value="">
				<input type="hidden" name="o_account" id="o_account" value="">
				<input type="hidden" name="discount_account" id="discount_account" value="">
                <dl class="w600">
                	<dt>债权转让标题：</dt>
                    <dd>
                                        <!--
					<select name="title" id="title">
						<option value="" selected="selected">请选择</option>
						<option value="结婚给丈母娘彩礼钱">结婚给丈母娘彩礼钱</option>
						<option value="低价买楼急需首付">低价买楼急需首付</option>
						<option value="辞职进修需学费">辞职进修需学费</option>
						<option value="小房换别墅需装修">小房换别墅需装修</option>
						<option value="小车换跑车需钱">小车换跑车需钱</option>
						<option value="扩大生意急需">扩大生意急需</option>
						<option value="消费购大件急需">消费购大件急需</option>
						<option value="外出观光旅游">外出观光旅游</option>
					</select>
                                        -->
						<input class="input" name="title" id="title" value="" />
                    </dd>
                </dl>
                <dl class="w600">
                	<dt>折让率：</dt>
                    <dd><input id="apr" name="apr" class="yzinput" onblur="checkApr()"> %（0.5%-11.5%）</dd>
                </dl>
                <dl class="w600">
                	<dt>折让后金额：</dt>
                    <dd><span id="zhje">0</span> 元</dd>
                </dl>
                <dl class="w600">
                	<dt>有效期：</dt>
                    <dd>
							<select class="yzinput" id="valid_time" name="valid_time">
								<option value="1">1天</option>
								<option value="2">2天</option>
								<option value="3" selected="selected">3天</option>
								<option value="4">4天</option>
								<option value="5">5天</option>
							</select>
                    </dd>
                </dl>
                <dl class="w600">
                	<dt>折让说明：</dt>
                    <dd><textarea name="content" id="content" style="width:300px;height:100px;" class="ckeditor"></textarea></dd>
                </dl>
                <div class="clear h20"></div>
                <div class="cb"><a href="javascript:void(0);" onclick="tosub();" class="ann"  style="margin-left:200px; width:160px; overflow:hidden;">确认转让</a></div>
                </form>
                <div class="clear h20"></div>
			</div>
            
        </div>
	</div>
</div>
<div class="clear h50"></div>
<?php include "./application/views/footer.php";?>